<?php
namespace app\redbag\model;

use app\BaseModel;
use think\facade\Db;

class Img extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_redbag_img';


    /**
     * @param $query
     * 查询范围
     */
    public function scopeStatus($query, $status){
        $query->where('status', '>', $status);
    }

    /**
     * @author chenniang
     * @DataTime: 2020-04-09 16:32
     * @功能说明:添加图片
     */
    public function imgAdd($insert){

        $insert['status'] = 1;

        $insert['create_time'] = time();

        $res = $this->insert($insert);

        return $res;

    }


    /**
     * @param $dis
     * @param $page
     * @功能说明:列表
     * @author chenniang
     * @DataTime: 2020-04-09 16:34
     */
    public function imgList($dis,$page){

        $data = $this->where($dis)->status(-1)->order('id desc')->paginate($page)->toArray();

        return $data;

    }


    /**
     * @author chenniang
     * @DataTime: 2020-04-09 16:43
     * @功能说明:详情
     */
    public function imgInfo($dis){

        $data = $this->where($dis)->status(-1)->find();

        return !empty($data)?$data->toArray():[];
    }


    /**
     * @author chenniang
     * @DataTime: 2020-04-09 16:44
     * @功能说明:编辑
     */
    public function imgUpdate($dis,$data){

        $res = $this->where($dis)->update($data);

        return $res;
    }
















}